package com.it.park.rms.common;

import java.io.Serializable;

/**
 * @author 分页工具
 *
 */
public class Page implements Serializable{
	
	private static final long serialVersionUID = 1L;

	/**
	 *当前页
	 */
	private int pageNow = 1;
	
	/**
	 *每页显示记录数
	 */
	private int pageSize = 10;
	
	/**
	 * 总记录数
	 */
	private int totalCount = 0;
	
	/**
	 * 总页数
	 */
	private int totalPageCount=0;
	
	/**
	 * 开始位置，从0开始
	 */
	@SuppressWarnings("unused")
	private int startPos;
	
	/**
	 * 是否有第一页
	 */
	@SuppressWarnings("unused")
	private boolean hasFirst;
	
	/**
	 * 是否有前一页
	 */
	@SuppressWarnings("unused")
	private boolean hasPre;
	
	/**
	 * 是否有下一页
	 */
	@SuppressWarnings("unused")
	private boolean hasNext;
	
	/**
	 * 是否有最后一页
	 */
	@SuppressWarnings("unused")
	private boolean hasLast;

	/**
	 * 
	 * @param pageNow 当前页
	 * @param totalCount 总记录
	 */
	public Page(Integer pageNow, int totalCount,int pageSize) {
		super();
		this.pageNow =( pageNow==null?1:pageNow);
		this.totalCount = totalCount;
		this.pageSize = pageSize;
	}
	
	/**
	 * 
	 * 总页数
	 */
	public int getTotalPageCount(){
		totalPageCount = (totalCount==0?1:totalCount-1)/pageSize+1;
		return totalPageCount;
	}

	public int getPageNow() {
		return pageNow;
	}

	public void setPageNow(int pageNow) {
		this.pageNow = pageNow;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}

	public int getStartPos() {
		if(pageNow <=0)
			pageNow = 1;
		return (pageNow - 1)*pageSize;
	}

	public void setStartPos(int startPos) {
		this.startPos = startPos;
	}

	/**
	 *是否是第一页 
	 */
	public boolean isHasFirst() {
		return (pageNow == 1)?false:true;
	}

	public void setHasFirst(boolean hasFirst) {
		this.hasFirst = hasFirst;
	}

	/**
	 *是否有首页 
	 */
	public boolean isHasPre() {
		return isHasFirst()?true:false;
	}

	public void setHasPre(boolean hasPre) {
		this.hasPre = hasPre;
	}

	/**
	 *是否有下一页 
	 */
	public boolean isHasNext() {
		return isHasLast()?true:false;
	}

	public void setHasNext(boolean hasNext) {
		this.hasNext = hasNext;
	}

	/**
	 *是否有尾页
	 */
	public boolean isHasLast() {
		return (pageNow == getTotalCount())?false:true;
	}

	public void setHasLast(boolean hasLast) {
		this.hasLast = hasLast;
	}

	public void setTotalPageCount(int totalPageCount) {
		this.totalPageCount = totalPageCount;
	}
	
	
	
}
